package com.cskaoyan.controller.wx.issue;

import com.cskaoyan.bean.MarketIssue;
import com.cskaoyan.bean.MarketIssueExample;
import com.cskaoyan.bean.vo.wx.issue.WxIssueListVo;
import com.cskaoyan.mapper.MarketIssueMapper;
import com.cskaoyan.service.wx.issue.WxIssueService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bwj
 * @Date: 2022/09/13/0:11
 * @Description:
 */
@Service
public class WxIssueServiceImpl implements WxIssueService {
    @Autowired
    MarketIssueMapper issueMapper;
    @Override
    public WxIssueListVo list(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        MarketIssueExample issueExample = new MarketIssueExample();
        List<MarketIssue> marketIssues = issueMapper.selectByExample(issueExample);
        PageInfo info=new PageInfo(marketIssues);
        WxIssueListVo listVo = new WxIssueListVo();
        listVo.setLimit(limit);
        listVo.setList(marketIssues.toArray());
        listVo.setPage(page);
        listVo.setPages(info.getPages());
        listVo.setTotal(info.getTotal());
        return listVo;
    }
}
